package design_mode.proxy.dynamic_proxy;


import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {
    private Object usbFactory;

    public void setUSBFactory(Object usbFactory) {
        this.usbFactory = usbFactory;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        int price = (int) method.invoke(usbFactory, args);
        System.out.println("厂家零售价： " + price);
        int finalprice = price + 40;
        System.out.println("最终价格： " + finalprice);

        return finalprice;
    }
}
